<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiArticleArctinyTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_article_arctiny';

    /**
     * Run the migrations.
     * @table qii_article_arctiny
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('文章ID');
            $table->unsignedInteger('uid')->default('0')->comment('添加此文章的作者ID');
            $table->unsignedInteger('viewnum')->default('0')->comment('查看次数统计');
            $table->unsignedInteger('category_id')->default('0')->comment('文章类别');
            $table->unsignedInteger('arctiny_id')->default('0')->comment('自关联文章ID(同一文章属于多个类别)');
            $table->unsignedSmallInteger('is_link')->default('0')->comment('是否跳转链接');
            $table->unsignedSmallInteger('is_top')->default('0')->comment('是否置顶(0不置顶 1置顶)');
            $table->unsignedInteger('status_id')->default('0')->comment('状态ID');
            $table->unsignedInteger('sortrank')->default('0')->comment('排序');
            $table->unsignedInteger('modified')->default('0')->comment('添加/修改时间');
            $table->unsignedTinyInteger('status')->default('1')->comment('状态 (0已删除,1正常)');

            $table->index(["arctiny_id"], 'arctiny');

            $table->index(["category_id", "sortrank", "status"], 'cate_sortrank');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
